<?php

/**
 * cuentas actions.
 *
 * @package    dirsac
 * @subpackage cuentas
 * @author     Miguel Flores
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class cuentasActions extends autocuentasActions
{
    public function executeIndex(sfWebRequest $request)
	{
		$this->cuenta_list = Doctrine::getTable('Cuenta')
			->createQuery('a')
			->execute();
			
		$this->filter = new CuentaFormFilter();
	}
	
	public function executeFilter(sfWebRequest $request)
	{
		$filter_values = $request->getParameter('cuenta_filters');
		$this->filter = new CuentaFormFilter($filter_values);
		$this->consulta = $this->filter->buildQuery($request->getParameter('cuenta_filters'));

		$this->cuenta_list = $this->consulta->execute();

		$this->setTemplate('index');
	}
	
	public function executeTransacciones(sfWebRequest $request) 
	{
		$this->cuenta = Doctrine::getTable('Cuenta')->find(array($request->getParameter('id')));
    	$this->forward404Unless($this->cuenta);
    	
    	$this->transacciones = Doctrine::getTable('Transaccion')
    		->createQuery('t')
    		->where("t.cuenta_id = '".$this->cuenta->getId()."'")
    		->execute();
	}

}
